﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Assets.Scripts.TDu3DWork;

namespace Assets.Scripts.TDuApp
{
    enum APP_TYPE
    {
        UNITYVR = 1 << 0,
        UNITY3D = 1 << 1,
        UNITYAR = 1 << 2,
    }

    class TDuAppMaker
    {
        public APP_TYPE m_appType;
        public string m_appCmdLine;
        TDuSceneCfgWorker m_sceneCfgWorker;

        public TDuAppMaker(string strCfgUrl)
        {
            m_sceneCfgWorker = new TDuSceneCfgWorker(strCfgUrl);
            m_appCmdLine = "";
            m_appType = APP_TYPE.UNITYVR;
        }

        public TDuAppMaker()
        {

        }

        public void prepareApp()
        {
            m_sceneCfgWorker.setVROr3D(true);
        }

        public IEnumerator initApp()
        {
            m_sceneCfgWorker.initComponets();
            m_sceneCfgWorker.initUI();

            if( m_sceneCfgWorker.getVROr3D())
            {
                m_sceneCfgWorker.initHands();
                m_sceneCfgWorker.initTeleport();
                yield return m_sceneCfgWorker.initVRDevice();
            }
            else
            {
                m_sceneCfgWorker.initCamera();
            }
        }

        public void startApp()
        {
            m_sceneCfgWorker.start();
        }

        public void runApp()
        {
            m_sceneCfgWorker.running();
        }

        public void lateRunApp()
        {
            m_sceneCfgWorker.lateRunning();
        }
    }
}

